<?php
/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of article
 *
 * @author Caroline
 */
class article {
    private $id;
    private $libelle;
    private $prixLocation;
    private $image;
    private $desc;
    private $caution;
    private $couleur;
    private $dimensions;
    private $poids;
    private $stock;
    private $leContexte;
    private $laMarque;

    //constructeur
    function __construct($libelle, $prixLocation, $image, $desc, $caution, $couleur, $dimensions, $poids, $stock, $laMarque, $leContexte) {
        $this->libelle = $libelle;
        $this->prixLocation = $prixLocation;
        $this->image = $image;
        $this->desc = $desc;
        $this->caution = $caution;
        $this->couleur = $couleur;
        $this->dimensions = $dimensions;
        $this->poids = $poids;
        $this->stock = $stock;
        $this->laMarque = $laMarque;
        $this->leContexte = $leContexte;
    }


    //accesseurs
    public function getId() {
        return $this->id;
    }

    public function getLibelle() {
        return $this->libelle;
    }

    public function getPrixLocation() {
        return $this->prixLocation;
    }

    public function getImage() {
        return $this->image;
    }

    public function getDesc() {
        return $this->desc;
    }

    public function getCaution() {
        return $this->caution;
    }

    public function getCouleur() {
        return $this->couleur;
    }

    public function getDimensions() {
        return $this->dimensions;
    }

    public function getPoids() {
        return $this->poids;
    }

    public function getStock() {
        return $this->stock;
    }

    public function getLeContexte() {
        return $this->leContexte;
    }

    public function getLaMarque() {
        return $this->laMarque;
    }

    

    //modificateurs
    public function setLibelle($libelle) {
        $this->libelle = $libelle;
    }

    public function setPrixLocation($prixLocation) {
        $this->prixLocation = $prixLocation;
    }

    public function setImage($image) {
        $this->image = $image;
    }

    public function setDesc($desc) {
        $this->desc = $desc;
    }

    public function setCaution($caution) {
        $this->caution = $caution;
    }

    public function setCouleur($couleur) {
        $this->couleur = $couleur;
    }

    public function setDimensions($dimensions) {
        $this->dimensions = $dimensions;
    }

    public function setPoids($poids) {
        $this->poids = $poids;
    }

    public function setStock($stock) {
        $this->stock = $stock;
    }

    public function setLeContexte($leContexte) {
        $this->leContexte = $leContexte;
    }
    
    public function setLaMarque($laMarque) {
        $this->laMarque = $laMarque;
    } 
    
    public function ajoutUnContexte($unContexte) {
        $this->lesContextes = $unContexte;
    }
    
    public function ajoutUneMarque($laMarque){
        $this->laMarque = $laMarque;
    }
           
    
    public function modifierArticle(Bdd $sql){            
        $req = "UPDATE produit
                WHERE pro_id         ='$this->id'
                SET pro_libelle      ='$this->libelle'
                    pro_prixLocation ='$this->prixLocation'
                    pro_image        ='$this->image'
                    pro_desc         ='$this->desc'
                    pro_caution      ='$this->caution'
                    pro_couleur      ='$this->couleur'
                    pro_dimensions   ='$this->dimensions'
                    pro_poids        ='$this->poids'
                    pro_stock        ='$this->stock'
                    pro_contexte     ='$this->leContexte'
                    pro_marque       ='$this->laMarque'
                
        $sql->execute($req)";
    }  

    public function ajoutArticle(Bdd $sql){        
        $new = "INSERT INTO article
                VALUES ('$this->id',
                        '$this->libelle',
                        '$this->prixLocation',
                        '$this->image',
                        '$this->desc',
                        '$this->caution',
                        '$this->couleur',
                        '$this->dimensions',
                        '$this->poids',
                        '$this->stock',
                        '$this->lesContextes',
                        '$this->laMarque')";

        $sql->execute($new);
    }     
    
    public function suprimerArticle(Bdd $sql){        
        $del = "DELETE FROM article
                WHERE art_id = '$this->id'";

        $sql->execute($del);        
    }
}
?>
